import request from '@/utils/request'

export function getOpenApp(index, size) {
  return request({
    url: '/api/data/v1/apps?index=' + index + '&size=' + size,
    method: 'get'
  })
}
export function getDeviceMessageList(appid, index = 0, size = 50) {
  return request({
    // url: 'http://218.11.10.94:11300/api/data/v1/app/' + appid + '/devices?index=' + index + '&size=' + size,
    url: '/api/data/v1/app/' + appid + '/devices?index=' + index + '&size=' + size,
    method: 'get',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
export function getGroupIDFromGroup() {
  return request({
    url: '/api/data/v1/usergroups',
    method: 'get',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
export function getUserIDFromUsers(ugIdx) {
  return request({
    url: '/api/data/v1/usergroup/' + ugIdx + '/users',
    method: 'get',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
export function postAppForm(formData) {
  return request({
    url: '/api/data/v1/app',
    method: 'post',
    data: formData,
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
// 获取应用详细信息
export function getAppDetailInf(appID) {
  return request({
    url: '/api/data/v1/app/' + appID,
    method: 'get',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
// 修改应用信息
export function putChangeAppInfo(changeDataForm) {
  return request({
    url: '/api/data/v1/app',
    method: 'put',
    data: changeDataForm,
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
// 获取具体用户信息
export function getUserDetailInfo(userid) {
  return request({
    url: '/api/data/v1/user/' + userid,
    method: 'get',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}

// 同步下级用户设备列表
export function syncAppData(app_id) {
  return request({
    url: '/api/data/v1/app/' + app_id + '/sync',
    method: 'post',
    headers: {
      token: '22515d092171424e8c7e9fb95171b123'
    }
  })
}
